package com.akka.demo.service;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import com.akka.demo.di.SpringExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by Administrator on 2018/2/26.
 */
@Service
public class DemoService {

    @Autowired
    private ActorSystem actorSystem;

    @Autowired
    private SpringExtension springExtension;

    public void startApp(Object msg) {
        ActorRef iotSupervisor = actorSystem.actorOf(springExtension.props("iotSupervisor"));
        iotSupervisor.tell(msg, ActorRef.noSender());
    }

    public void stopApp() {
        actorSystem.terminate();
    }
}
